package com.cratos.xxgram.platf.util;

import com.google.i18n.phonenumbers.PhoneNumberUtil;
import com.google.i18n.phonenumbers.Phonenumber.PhoneNumber;
/**
 * 国际电话号码校验
 * @author fk
 */
public class Phones {
	private static PhoneNumberUtil phoneNumberUtil = PhoneNumberUtil.getInstance();

	public static boolean checkPhoneNumber(String phoneNumber, int ccode) {
		try {
			long phone = Long.parseLong(phoneNumber);
			PhoneNumber pn = new PhoneNumber();
			pn.setCountryCode(ccode);
			pn.setNationalNumber(phone);
			return phoneNumberUtil.isValidNumber(pn);
		} catch (Exception e) {
			e.printStackTrace();
			return false;
		}
	}

	public static void main(String[] args) {

		System.out.println(checkPhoneNumber("962733985", 855));
		System.out.println(checkPhoneNumber("16666666666", 86));
		System.out.println(checkPhoneNumber("13044889046", 86));

	}
}
